<?php
	/*
	 *	NOTE: createschool from write_functions.php lacks parameters.
	 *			- using manual query
	 */
	session_start();
	include("checkSchool.php");
	include("write_functions.php");
	connect("localhost", "root", "", "gradegriddatabase");
	include("fetchData.php");
		
	if($clean){
		$data = fetchAccountDetails();
		
		$que = "INSERT INTO school (account_id, school_name, college_name, department_name, president, principal, dean, college_secretary,
				department_chair, country, zip_code, city_province, municipality, street, description, contact_info_1, contact_info_2,
				contact_info_3)
				VALUES ('$data[account_id]',
				'$_POST[school]',
				'$_POST[college]',
				'$_POST[dept]',
				'$_POST[pres]',
				'$_POST[prin]',
				'$_POST[dean]',
				'$_POST[colSec]',
				'$_POST[deptChair]',
				'$_POST[country]',
				'$_POST[zip]',
				'$_POST[city]',
				'$_POST[municipality]',
				'$_POST[street]',
				'$_POST[desc]',
				'$_POST[num1]',
				'$_POST[num2]',
				'$_POST[num3]')";
		$result = mysql_query($que);
		if(!$result){
			echo 'Error: ' . mysql_error();
		}
		mysql_close();
?>
		<head><title>GradeGrid - School Addition Success</title></head>
		<body>
			<div style="position:absolute; top:-60px; margin-top:50%; left:-183px; margin-left:50%;">
				<h3 align="center">The school had been added successfully!<br/>What would you like to do?</h3>
				<div align="center">
					<a href="addSchool.php" onClick="window.opener.location='settings.php?page=school'">Add a new school</a>
					 OR 
					<a id="close" onClick="window.close(); window.opener.location='settings.php?page=school'" style="text-decoration:underline; color:#03F" onMouseOver="document.getElementById('close').style.cursor='pointer'">Close this window</a>
				</div>
			</div>
			<div style="font-size:9px; position:absolute; bottom:10px; left:-40px; margin-left:50%;" align="center">GradeGrid Copyright</div>
		</body>
<?php
	} else {
		echo $error;
		echo "<br/><a id=\"close\" onClick=\"history.back()\" style=\"text-decoration:underline; color:#03F\" onMouseOver=\"document.getElementById('close').style.cursor='pointer'\">Click here to return to your form</a></div>";
	}
?>